import React, { createContext, useState, useContext } from 'react'
import { useLocalStorage } from '@rehooks/local-storage'

export const AuthContext = createContext();
export const useAuth = () => useContext(AuthContext)

const AuthProvider = ({ children }) => {
    const [user, setUser, deleteUser] = useLocalStorage('user',{});

    return (
        <AuthContext.Provider value={{ user, setUser, deleteUser }}>
            {children}
        </AuthContext.Provider>
    )
}

export default AuthProvider